package com.qq.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.qq.bean.LikeDynamics;
import com.qq.service.LikeDynamicsServise;
import com.qq.service.impl.LikeDynamicsServiceImpl;
@WebServlet("/likedynamics.do")
public class LikeDynamicsServlet extends HttpServlet{
	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		LikeDynamicsServise lds  = new LikeDynamicsServiceImpl();
		HttpSession session = request.getSession();
		int dynamics_id = Integer.parseInt(request.getParameter("dynamics_id"));
		int user_id = Integer.parseInt(request.getParameter("user_id"));
		LikeDynamics likedy = new LikeDynamics(dynamics_id,user_id);
		int likedys = lds.insertLikeDy(likedy);
//		List<String> nicknameAll = lds.selectLikedyNickName(user_id);
//		session.setAttribute("nicknameAll", nicknameAll);
		ObjectMapper mapper = new ObjectMapper();
		String json = mapper.writeValueAsString(likedys);
		response.setContentType("application/json;charset=utf-8");
		mapper.writeValue(response.getWriter(), json);
	}

}
